<?php
namespace app\admin\controller;
use cmf\controller\AdminBaseController;
use app\admin\model\QuestionModel;
use think\Request;
use think\Validate;

class QuestionController extends AdminBaseController
{
	public function editques($id)
	{
		$quesModel = new QuestionModel();
		$data = $quesModel->getQuesDataById($id);
        $this->assign([
            "data"=>$data
        ]);
        return $this->fetch();
	}
	public function updateques(Request $request, $id)
	{
		 $data = $request->post();
		 $model = new QuestionModel();
		if($model->doEdit($data,$id)){
            $this->success("修改成功","Order/question");
        }else{
            $this->error("修改失败");
        }

	}
	    /**
     * 显示创建资源表单页.
     *
     * @return \think\Response
     */
    public function create()
    {
        return $this->fetch();
    }
    public function save(Request $request){
    	$data = $request->post();
    	$model = new QuestionModel();
		if($model->doAdd($data)){
            $this->success("修改添加","Order/question");
        }else{
            $this->error("修改失败");
        }
    }
    public function deleteques($id)
    {
        $model = new QuestionModel();
        if($model->doDel($id)){
            $this->success("删除成功");
        }else{
            $this->error('删除失败');
        }
    }
}